using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.CodeRush.Core;

namespace DX_SourceOutliner
{
    public class ActiveDocumentOnlyProcessor : ITreeProcessor
    {

        private string _activeDocumentName;

        /// <summary>
        /// Initializes a new instance of the ActiveDocumentOnlyProcessor class.
        /// </summary>
        /// <param name="activeDocumentName"></param>
        public ActiveDocumentOnlyProcessor(string activeDocumentName)
        {
            _activeDocumentName = activeDocumentName;
        }

        public IEnumerable<TreeNode> Process(IEnumerable<TreeNode> nodes)
        {
            if (string.IsNullOrEmpty(_activeDocumentName))
                return nodes;

            return nodes.Where(n => (n.Tag as ISourceTreeNode).ElementName == _activeDocumentName);
        }

    }
}
